package com.zhanghe.study.springboot.configuration.bean;

import org.springframework.boot.web.servlet.ServletContextInitializer;
import org.springframework.stereotype.Component;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletRegistration;

/**
 * @author zh
 * @date 2021/9/27 17:08
 */
@Component
public class ServletRegistConfiguration implements ServletContextInitializer {
    @Override
    public void onStartup(ServletContext servletContext) throws ServletException {
        ServletRegistration.Dynamic dynamic = servletContext.addServlet("registServlet", RegistServlet.class);
        // 地址映射
        dynamic.addMapping("/regist");
        // servlet的初始参数
        dynamic.setInitParameter("name","王五");
    }
}
